Skip to content

fix(mesonlsp): improved root detection #3775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025

Conversation

SpikedPaladin
Copy link
Contributor

This commit enhances root directory detection of mesonlsp language server.
Current behavior:
root is set on first meson file user is opened
New behavior:
root is set to parent of meson.build with project function call

@SpikedPaladin SpikedPaladin force-pushed the fix-mesonlsp-root branch 2 times, most recently from 1a3a3f7 to c9000bb Compare April 28, 2025 09:58
This commit enhances root directory detection of mesonlsp language
server.
Current behavior:
root is set on first meson file user is opened
New behavior:
root is set to parent of meson.build with project function call
Comment on lines +15 to +23
for line in io.lines(f) do
-- skip meson comments
if not line:match '^%s*#.*' then
local str = line:gsub('%s+', '')
if str ~= '' then
if str:match '^project%(' then
return true
else
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vim.filetype.match() exists for this purpose. However,

vim.filetype.match({ filename = f, contents = 'project' })

seems to return "meson" even if the file doesn't contain "project", which isn't what you want here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For mesonlsp root_dir is required to be at folder with 'project' file. If root will be in different place all file will be underlined with red. I just take code from vala_ls which finds project root perfectly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just take code from vala_ls which finds project root perfectly.

Yeah, I'm trying to find more concise patterns so that we don't have to maintain 10x as much code in all of these configs.

@justinmk justinmk merged commit 48003b3 into neovim:master Apr 28, 2025
10 checks passed
@SpikedPaladin SpikedPaladin deleted the fix-mesonlsp-root branch April 28, 2025 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants